'''
计算a+aa+aaa+aaaa....的值，第一个数是a，第二个数是加多少次

num1 = int(input("数字="))
num2 = int(input("加数="))
res = 0
res1 = 0
for i in range(1,num2+1):
    res = res * 10 + num1
    res1 += res
print(res1)
'''
import math
from _pyrepl.commands import end

'''
定义一个factorial函数，计算数的阶乘


def factorial(n):
    if n < 0:
        return f"{n}没有阶乘"
    cur = 1
    for i in range (1,n+1):
        print(i)
        cur *= i
    return cur
print(factorial(-5))
'''

'''
给定半径计算圆的面积

import math
def Circle(radius):
    Area = math.pi * radius ** 2
    return round(Area,2)
print(Circle(5))
'''

'''
定义一个函数，打印指定范围内的所有素数

# def prime(num):
#     if num <= 1:
#         return False
#     for i in range(2, num):
#         if num % i == 0:
#             return False
#     return True
# def math(start, end):
#     for i in range(start, end+1):
#         if prime(i):
#           print(f'{i}是素数')
# math(5,20 )


# 优化后
def prime(num):
    if num <= 1:
        return False
    for i in range(2, int(num**0.5) + 1):
        if num % i == 0:
            return False
    return True
'''

'''
定义一个函数，计算1到n的所有平方和

def Sumsquares(num):
    res = 0
    res1 = 0
    for i in range(1,num+1):
        res = i ** 2
        res1 += res
    return res1
print(Sumsquares(9))
'''